package com.znsd.zl.house.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.znsd.zl.house.entity.HouseImageEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @ClassName THouseImage
 * @Description 描述
 * @author jaypdd
 * @email jaypdd@163.com
 * @date 2020-08-26 23:20:43
 * @Version v1.0
 */
@Mapper
public interface HouseImageDao extends BaseMapper<HouseImageEntity> {

	/**
	 * 查询轮播图
	 * @return
	 */
	@Select("select * from t_house_image where slideshow=1")
	List<HouseImageEntity> firstFive();

	/**
	 * 加入轮播图
	 * @param id
	 */
	@Update("update t_house_image set slideshow=1 where id=#{id}")
	void joinSlideshow(Integer id);

	/**
	 * 撤销轮播图
	 * @param id
	 */
	@Update("update t_house_image set slideshow=0 where id=#{id}")
	void reSlideshow(Integer id);

	/**
	 * 按房源Id查询
	 * @param houseId
	 * @return
	 */
	@Select("select * from t_house_image where house_id = #{houseId} and slideshow=0")
	List<HouseImageEntity> findByHouseImage(Integer houseId);



}
